<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .errorInfo{
            color: red;
            font-size: 12px;
        }
    </style>
    <script src="/html/js/axios.min.js"></script>
    <script src="/html/js/ajax.js"></script>
    <script src="/html/js/util.js"></script>
    <script>
        let money = "";
        window.onload = function () {
            money = getQuery("money");
        }

        async function add() {
            let userBean = await ajaxGet("/user/getLoginUser");
            let info=await ajaxGet("/order/add"
                , {name: getObject("name").value,
            address:getObject("area").value,phone:getObject("phone").value,
            money:money,"userBean.id":userBean.id})
            if (info=="ok"){
                location.href="/html/custom/success.html";
            }else {
                let  divArray=document.getElementsByClassName("errorInfo");
                for (let i=0;i<divArray.length;i++){
                    divArray[i].innerHTML="";
                }
                for(let i=0;i<info.length;i++){
                    let obj=info[i];
                    getObject(obj.field+"Div").innerText=obj.defaultMessage;
                }
            }
        }
    </script>
</head>
<body>
<div>
    <div style="margin: 0 auto;width: 50%;height: 50%;margin-top: 100px">
        <span style="font-size: 30px;font-weight: bolder">请完善订单资料</span><br>
        收货人:<input type="text" id="name" style="margin-top: 20px"><br>
        <div id="nameDiv" class="errorInfo"></div>
        送货地址:<input type="text" id="area" style="margin-top: 20px"><br>
        <div id="addressDiv" class="errorInfo"></div>
        收货人电话:<input type="text" id="phone" style="margin-top: 20px"><br>
        <div id="phoneDiv" class="errorInfo"></div>
        <input type="button" value="提交订单" onclick="add()" style="margin-top: 20px">
    </div>
</div>
</body>
</html>